import { userRequest } from '@/utils/request'

enum API {
    GET_USERLIST = '/admin/acl/user',
    ADD_USER = '/admin/acl/user/save',
    UPDATE_USER = '/admin/acl/user/update',
    DELETE_USER = '/admin/acl/user/remove',
    GET_ROLELIST = '/admin/acl/user/toAssign',
    ASSIGN_ROLE = '/admin/acl/user/doAssignRole',
    GET_ROLE = '/admin/acl/user/getRole',
    BATCH_DELETE = '/admin/acl/user/batchRemove'
}

export const reqGetUserList = (page: number, limit: number, username: string) =>
    userRequest.get<any, any>(API.GET_USERLIST + `/${page}/${limit}?username=${username}`)

export const reqAddUser = (data: any) =>
    userRequest.post<any, any>(API.ADD_USER, data)

export const reqUpdateUser = (data: any) =>
    userRequest.put<any, any>(API.UPDATE_USER, data)

export const reqDeleteUser = (id: number) =>
    userRequest.delete<any, any>(API.DELETE_USER + `/${id}`)
export const reqGetRoleList = (userId: number) =>
    userRequest.get<any, any>(API.GET_ROLELIST + `/${userId}`)
export const reqAssignRole = (data: any) =>
    userRequest.post<any, any>(API.ASSIGN_ROLE, data)
export const reqGetRole = (userId: number) =>
    userRequest.get<any, any>(API.GET_ROLE + `/${userId}`)
export const reqBatchDelete = (data: any) =>
    userRequest.delete<any, any>(API.BATCH_DELETE, { data })